package mysql

import (
	"context"
	"app/pb"
)

func (c *db) CreateUser(ctx context.Context, username string ,password string) (*pb.UserInfo, error) {

	row, err := c.Exec("INSERT INTO user (username ,password) values (?,?)",username,password)

	if err != nil {
		return nil, err
	}

	var ui = &pb.UserInfo{}

	id , err := row.LastInsertId()
	if err != nil {
		return nil, err
	}

	ui.Id = id
	ui.Username = username

	return ui, nil
}
